package com.example.spring.Controller;

import com.example.spring.Dto.AddressCount;
import com.example.spring.Dto.Company;
import com.example.spring.Dto.CompanyTypeCount;
import com.example.spring.service.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CompanyController {

    @Autowired
    private CompanyService companyService;


    //获取companies表中公司姓名 法人代表姓名 公司区域
    @GetMapping("/companies")
    public List<Company> getCompanies(@RequestParam(defaultValue = "300") int limit) {
        return companyService.getValidCompanies(limit);
    }

    //获取各个区域的个数
    @GetMapping("/address-counts")
    public List<AddressCount> getAddressCounts() {
        return companyService.getAddressCounts();
    }

    //公司类型占比
    @GetMapping("/top-company-type-counts")
    public List<CompanyTypeCount> getTopCompanyTypeCounts() {
        return companyService.getTopCompanyTypeCounts();
    }


    @GetMapping("/companiescount")
    public Long getCompanyCount() {
        return companyService.getCompanyCount();
    }
}
